package com.x.crm.dao;

import com.x.crm.model.OrderCar;
import com.x.framework.dao.BaseDao;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class OrderCarDao extends BaseDao{


	private final static String baseSelectOrderCarListSql = "SELECT * FROM  CRM_ORDER_CAR  I " +
			"WHERE 1=1 ";

	public List<OrderCar> selectOrderCarList(OrderCar orderCar) throws Exception {
		StringBuilder sb = new StringBuilder(baseSelectOrderCarListSql);
		List<Object> params = new ArrayList<Object>();
		searchBasicCondition(orderCar, sb, params);
		sb.append(" ORDER BY I.ORDER_CREATE_TIME DESC");
		return this.queryForList(sb.toString(), OrderCar.class, params, orderCar);
	}


	private void searchBasicCondition(OrderCar orderCar, StringBuilder sb, List<Object> params) {
		System.out.println(orderCar.getFollowOrderId());
		if (this.isString(orderCar.getFollowOrderId())) {
			System.out.println("-------------------");
			sb.append("AND I.FOLLOW_ORDER_ID = ? ");
			params.add(orderCar.getFollowOrderId());
		}
	}


}
